//
//  CheckViewController.m
//  体育
//
//  Created by  on 2022/10/25.
//

#import "CheckViewController.h"
#import "CheckCell.h"

@interface CheckViewController ()
@property (strong, nonatomic) IBOutlet UILabel *content;
@property (strong, nonatomic) IBOutlet UICollectionView *collection;
@end

@implementation CheckViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUI];
}
- (void)initUI{
    self.title = LS(@"备注");
    self.content.text = self.model.remark;
    [self.rightBtn setImage:[UIImage imageNamed:@"删除_未选中"] forState:UIControlStateNormal];
    [self.rightBtn setTitle:@"" forState:UIControlStateNormal];
    [self.collection registerNib:[CheckCell nib] forCellWithReuseIdentifier:[CheckCell ID]];
}

- (void)rightBtnAction{
    [DataTool delete:self.model complete:^(BOOL success) {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }];
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.model.imgs.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    CheckCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:[CheckCell ID] forIndexPath:indexPath];
    cell.img.image = [UIImage imageWithData:self.model.imgs[indexPath.row]];
    return  cell;
}

#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
}

#pragma mark - UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return  CGSizeMake(SCREEN_WIDTH - 16 - 40,180.0 / 260 * SCREEN_WIDTH - 16 - 40);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return  UIEdgeInsetsMake(0, 20, 20, 20);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 20;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 20;
}

@end
